#!/usr/bin/env bash
set -e
set -u
set -o pipefail

configopt=all

__private_print_help() {
    echo "script usage: $(basename $0)" &&\
        echo "              [-a] configure all" &&\
        echo "              [-g] configure git"
}

while getopts 'agh' OPTION; do
    case "$OPTION" in
        a)
            configopt=all
            ;;
        g)
            configopt=git
            ;;
	h)
	    __private_print_help
	    exit
	    ;;
        ?)
            __private_print_help >&2
            exit 1
            ;;
    esac
done
shift "$(($OPTIND -1))"

__private_configure_git() {
    echo "Configuring git..."
    git config --global core.editor "emacs -nw"
    git config --global core.excludesfile '~/.gitignore_global'
    git config --local user.email "vaeringjar@peers.community"
    git config --local user.name "vaeringjar"
}

__private_main() {
    if [ "$configopt" = "all" ]; then
        __private_configure_git
    elif [ "$configopt" = "git" ]; then
        __private_configure_git
    elif [ "$configopt" = "" ]; then
        echo "No configopt set."
        __private_print_help
        exit 1
    else
        __private_print_help
    fi
    exit
}

__private_main
